<template>
  <div class="relative w-full h-full select-none">
    <div v-show="asr.touchStatus && asr.asring" :class="$style['controller-input-siri']">
      <img src="/src/assets/white-theme/apng/asr.png" class="w-[76%] h-[80px] object-contain">
      <!-- <div id="siri-container" class="w-full h-[80px] object-cover" /> -->
      <p>{{ asr.asrText }}</p>
    </div>
    <button id="x-asr-btn" class="select-none"
      :class="{ [$style['controller-input-asr']]: true, [$style['touched']]: asr.touchStatus && asr.asring }"
      @touchstart.prevent="asr.onTouchstart">
      <div :class="$style['controller-input-asr-bg']">
        <div :class="$style['controller-input-asr-button']" class="flc relative">
          <!-- <icon-loading v-if="asr.touchStatus && !asr.asring" /> -->
          <div v-if="asr.touchStatus && !asr.asring" :class="$style['controller-loading']"></div>
          <icon-font name="h5-asr" />
          <span class="ml-10px z-3">长按说话</span>
        </div>
      </div>
    </button>
  </div>
</template>

<script
  lang="ts"
  setup
  name="ControllerInputText"
>
import { useAsrStore } from '@/store/asr'

const asr = useAsrStore()

</script>

<style
  module 
  lang="scss"
>
.controller-input-asr {
  @apply w-full relative z-1 select-none;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 23px;
  padding: 3px;

  .controller-input-asr-bg {
    @apply w-full h-full;
    background: rgba(255, 255, 255, 0.45);
    border-radius: 23px;
    transition: padding 0.3s;
  }

  .controller-input-asr-button {
    @apply w-full h-full;
    background: linear-gradient(180deg, #F0F7FF 0%, #CEE2F8 100%);
    box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.25);
    border-radius: 20px;
    border: 1px solid rgba(195, 213, 235, 1);
    font-size: 14px;
    color: #3B5379;
    font-weight: bold;
    transition: all 0.3s;
  }

  &.touched {
    .controller-input-asr-bg {
      padding: 2.5px;
    }

    .controller-input-asr-button {
      color: rgba(70, 115, 238, 1);
      border-color: rgba(70, 115, 238, 1);
      background: linear-gradient(rgba(50, 123, 232, 0.2), rgba(50, 123, 232, 0.2)), linear-gradient(180deg, rgba(222, 235, 254, 1) 0%, rgba(190, 215, 242, 1) 100%);
    }
  }
}

.controller-input-siri {
  @apply fixed left-0 w-full flex flex-col items-center;
  bottom: 110px;

  p {
    width: 254px;
    font-size: 13px;
    line-height: 1.5;
    text-align: center;
  }
}


@keyframes shimmer {
  to {
    background-position: -50% 0;
  }
}

.controller-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  border-radius: 25px;
  background-image: linear-gradient(-60deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(226, 238, 252, 0.5) 40px,
      rgba(0, 0, 0, 0) 80px);
  background-size: 300%;
  background-position: 0% 0;
  animation: shimmer 1.5s infinite;
}
</style>
